<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>添加用户名</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__PUBLIC__/css/font.css">
    <link rel="stylesheet" href="__PUBLIC__/css/xadmin.css">
    <style type="text/css">
      .displaynone{
        display: none;
      }
    </style>
  </head>
  <body>
  <div class="x-body">
    <form class="layui-form" id="uploadForm">
        <label for="L_email" class="layui-form-label">
            <span class="x-red">*</span>产品标题名称
        </label>
        <div class="layui-input-inline">
            <input type="text" id="sort" name="sort" required="" lay-verify="sort"
            autocomplete="off" class="layui-input">
        </div>
      <div class="layui-form-item" style="text-align: center;margin-top:20px;">
        <button  class="layui-btn" lay-filter="add" lay-submit="">
            开始上传
        </button>
      </div>
    </form>
  </div>
  </body>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="__PUBLIC__/js/xadmin.js"></script>
<script type="text/javascript">
   layui.use(['form','layer'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          form.on('submit(add)',function(){
            var sort = $('#sort').val();
            if(sort == ''){
              layer.msg('请输入产品标题!!');
              return false;
            }
              $.ajax({
                  url:"{:U('add_sort')}",
                  type:"post",
                  // Form数据
                  data:{sort:sort},
                  success:function(data){
                      if(data==1){
                        layer.alert("增加成功", {icon: 6},function(){
                          // 获得frame索引
                          var index = parent.layer.getFrameIndex(window.name);
                          //关闭当前frame
                          parent.layer.close(index);
                        });
                      }else{
                        layer.msg('数据未添加成功');
                      }
                  }
              });
              return false;
          }) 
  })
</script>
</html>